﻿#include "ImageReader.h"


QByteArray CImageReader::readImageBase64(QString strFile)
{
	QByteArray base64;

	if (strFile.isEmpty())
	{
		return base64;
	}

	QByteArray bytes = openFile(strFile);

	base64 = bytes.toBase64();

	return base64;
}

QByteArray CImageReader::readBinaryImage(QString strFile)
{
	QByteArray binary;

	if (strFile.isEmpty())
	{
		return binary;
	}
	binary = openFile(strFile);

	binary = binary.toHex();

	return binary;
}

QByteArray CImageReader::openFile(QString strFile)
{
	QByteArray bytes;

	if (strFile.isEmpty())
	{
		return bytes;
	}

	QFile file(strFile);

	if (!file.open(QIODevice::ReadOnly))
	{
		return bytes;
	}

	bytes = file.readAll();

	return bytes;
}
